//控制单位放地雷
params ["_unit"];


if((typeOf _unit) find "_mine" < 0) exitWith{};


private ["_list", "_pos", "_mine"];

//寻找周围房子和道路生成地雷
_list = [];
_list = (nearestObjects [_unit, ["House"], 200]) + (_unit nearRoads 250);

if(count _list == 0) exitWith{};

_pos = position (selectRandom _list);
_mine = (selectRandom asp_mine_ed) createVehicle _pos;

if(Param_Debug == 1) then
{
	private _marker = createMarker [format["marker_mine_%1", count AllMines], getPos _mine];
	_marker setMarkerShape "ICON";
	_marker setMarkerColor "ColorRed";
	_marker setMarkerType "hd_join";
};

//50几率放ide
if(random 100 > 50) then
{
	_pos = position (selectRandom _list);
	_mine = (selectRandom asp_mine_ide_ed) createVehicle _pos;
	
	//添加触发器
	private _trg = createTrigger ["EmptyDetector", _pos];
	_trg setVariable ["v_unit", _unit];
	_trg setVariable ["v_mine", _mine];
	_trg setTriggerArea [3, 3, 0, false];
	_trg setTriggerActivation ["ANYPLAYER", "PRESENT", false];
	_trg setTriggerStatements ["this", "if(alive (thisTrigger getVariable 'v_unit')) then {(thisTrigger getVariable 'v_mine') setDamage 1}", ""];//_mine setDamage 1
	
	if(Param_Debug == 1) then
	{
		private _marker = createMarker [format["marker_mine_%1", count AllMines], getPos _mine];
		_marker setMarkerShape "ICON";
		_marker setMarkerColor "ColorGreen";
		_marker setMarkerType "hd_join";
	};

};



